package com.dk.MQ;

import com.dk.dto.LogServerDTO;
import com.dk.em.Result;
import com.dk.mapper.MqLogMapper;
import com.dk.pojo.MqLog;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/*MQ消费*/
@Component
@RocketMQMessageListener(consumerGroup = "2209-MQ",topic = "loginTopic")
public class ConsumerMQ implements RocketMQListener<LogServerDTO> {

    @Autowired
    private MqLogMapper mqLogMapper;

    @Override
    public void onMessage(LogServerDTO dto) {
        System.out.println("1接收消息 -------               -----------------        ----------------");
        MqLog mqLog = new MqLog();
        BeanUtils.copyProperties(dto, mqLog);
        int i = mqLogMapper.insertSelective(mqLog);
        if (i >0){
            System.out.println("日志服务存储成功");
        }
        return;
    }
}
